package com.hlt.controller.admin;

import com.hlt.dto.UserStatsPageQueryDTO;
import com.hlt.entity.UserStats;
import com.hlt.result.PageResult;
import com.hlt.result.Result;
import com.hlt.service.IUserStatsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/userStats")
@Controller("adminStatsController")
@Slf4j
@Api(tags = "统计接口")
public class UserStatsController {

    @Autowired
    private IUserStatsService userStatsService;

    /**
     * 分页查询
     */
    @PostMapping("/page")
    @ApiOperation("分页查询")
    public Result page(@RequestBody UserStatsPageQueryDTO userStatsPageQueryDTO) {
        log.info("分页查询：{}",userStatsPageQueryDTO);
        PageResult pageResult = userStatsService.pageQuery(userStatsPageQueryDTO);
        return Result.success(pageResult);
    }

    /**
     * 修改
     */
    @PutMapping("/update")
    @ApiOperation("修改")
    public Result update(@RequestBody UserStats userStats) {
        log.info("修改：{}",userStats);
        userStatsService.updateById(userStats);
        return Result.success();
    }

}
